package com.health.medicine.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.health.common.common.BaseResponse;
import com.health.common.common.ResultUtils;
import com.health.medicine.model.dto.medicine.PageQueryDrugInfoRequest;
import com.health.medicine.model.entity.Manufacturer;
import com.health.medicine.model.entity.MedicineInfo;
import com.health.medicine.service.MedicineInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhexueqi
 * @ClassName MedicineController
 * @since 2024/8/31    15:25
 */
@RestController
@RequestMapping("/medicine")
public class MedicineController {

    @Resource
    private MedicineInfoService medicineInfoService;

    /**
     * 分页查询药品列表
     */
    @PostMapping("/page")
    public Page<MedicineInfo> list(@RequestBody PageQueryDrugInfoRequest pageQueryDrugInfoRequest) {
        return  medicineInfoService.pageDrugInfo(pageQueryDrugInfoRequest);
    }

    /**
     * 根据溯源码查询对应生产单位信息
     * @param medicineCode
     */
    @GetMapping("/getManufacturerByCode")
    public BaseResponse<Manufacturer> getManufacturerByCode(@RequestParam("medicineCode") String medicineCode) {
        return ResultUtils.success(medicineInfoService.getManufacturerByCode(medicineCode));
    }

    /**
     * 根据溯源码查询对应药品信息
     * @param medicineCode
     */
    @GetMapping("/getDrugInfoByCode")
    public BaseResponse<MedicineInfo> getDrugInfoByCode(@RequestParam("medicineCode") String medicineCode) {
        return ResultUtils.success(medicineInfoService.getDrugInfoByCode(medicineCode));
    }
}
